package com.atgm.mall.gmmallperimall.controller;

import com.atgm.common.utils.R;
import com.atgm.mall.gmmallperimall.entity.PeriGoodsEntity;
import com.atgm.mall.gmmallperimall.service.PeriGoodsService;
import com.atgm.mall.gmmallperimall.vo.resp.PeriGoodsDetailVo;
import com.atgm.mall.gmmallperimall.vo.resp.PeriGoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 周边商品信息
 */
@RestController
@RequestMapping("gmmallperimall/perigoods")
public class PeriGoodsController {

    @Autowired
    private PeriGoodsService periGoodsService;

    /**
     * 首页优惠周边商品
     * @return
     */
    @GetMapping("/list")
    public R getGoodsInfoByTheme() {
        List<PeriGoodsVo> list = periGoodsService.queryGoodsListByTheme();
        return R.ok().setData(list);
    }

    @GetMapping("/infos")
    public R getPeriGoodsInfoByIds(@RequestParam("ids") List<Long> ids) {
        List<PeriGoodsEntity> list = periGoodsService.queryGoodsInfoByIds(ids);
        return R.ok().setData(list);
    }

    @GetMapping("/info/{id}")
    public R getPeriGoodsDetailById(@PathVariable("id") Long id) {
        PeriGoodsDetailVo periGoodsDetailVo = periGoodsService.queryPeriGoodsDetailById(id);
        return R.ok().setData(periGoodsDetailVo);
    }

}
